package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class Deloperation implements Interface{
    @Override
    public void work(BookList bookList) {
        System.out.println("输入你要删除的图书的书名：");
        Scanner scanner=new Scanner(System.in);
        String book=scanner.nextLine();
        int Quantity=bookList.getQuantity();
        int inde=-1;
        for (int i = 0; i < Quantity; i++) {
            Book book1 = bookList.getpoi (i);
            if (book.equals(book1.getName())) {
               inde=i;
               bookList.Del(inde,Quantity);
               bookList.setQuantity(Quantity-1);
               break;
            }
            if (inde == -1) {
            System.out.println("没有你要删除的书");
            }
            System.out.println("删除成功");
        }
    }
}
